package fun.tan90.device.main.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import fun.tan90.device.main.mapper.db1.DeviceInfoMapper;
import fun.tan90.device.main.model.dataobject.db1.DeviceInfo;
import org.apache.ibatis.solon.annotation.Db;
import org.noear.solon.annotation.Component;
import org.noear.solon.data.annotation.Cache;

@Component
public class DeviceInfoService {

    @Db("db1")
    DeviceInfoMapper deviceInfoMapper;

    @Cache(key = "${deviceCode}")
    public DeviceInfo deviceInfo(String deviceCode) {
        return deviceInfoMapper.selectOne(Wrappers.lambdaQuery(DeviceInfo.class).select(DeviceInfo::getDeviceType).eq(DeviceInfo::getDeviceCode, deviceCode));
    }
}
